package pers.cz.codegen.describe;

/**
 * @program: Jef-code-generator
 * @description: java枚举类
 * @author: Cheng Zhi
 * @create: 2023-08-31 15:20
 **/
public class JavaEnum extends AbstractJavaElement {

    public static final String descPlace = "##D";
    private String enumComment = "/**\n" +
            "     *  " + descPlace + "\n" +
            "     */";

    public JavaEnum(String name) {
        setName(name);
    }

    public JavaEnum(String name, String desc) {
        setName(name);
        setComment(desc);

    }

    @Override
    public void setComment(String myComment) {
        if (myComment == null) {
            return;
        }
        comment = enumComment.replace(descPlace, myComment);
    }

    @Override
    public String toCode() {
        StringBuilder sb = new StringBuilder();
        sb.append(TAB_SYMBOL);
        sb.append(getComment());
        sb.append(LINE_SYMBOL);
        sb.append(TAB_SYMBOL);
        sb.append(getName());
        // 处理逗号的放在JavaUnit中
        return sb.toString();
    }
}
